﻿using System;
using System.Net;
using Microsoft.TeamFoundation.Client;
using NUnit.Framework;

namespace TfsWrapper.Tests
{
	public abstract class TfsTest
	{
		protected TfsTeamProjectCollection Tfs;

		[SetUp]
		public void BaseSetup()
		{
            // for self hosted TFS this should be the TFS username and password, optionally including domain
            // for hosted TFS (visualstudio.com) user is the alternate credentials username (though the Live account email seems to work too)
            // and password is the alternate credentials password. No domain (##LIVE##) seems to be necessary
            var networkCredential = new NetworkCredential("simoneb", "{password}");

		    Tfs = new TfsTeamProjectCollection(new Uri("https://simoneb.visualstudio.com/DefaultCollection"),
                    new TfsClientCredentials(new BasicAuthCredential(networkCredential))
					{
					    AllowInteractive = false
					});
			
            Tfs.Authenticate();
            Tfs.EnsureAuthenticated();
		}

		[TearDown]
		public void Teardown()
		{
			Tfs.Dispose();
		}
	}
}